<%@ page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
${aier_doctype}
<html <s:property value="aier_html_xmlns" escape="false"/>>
<head>
<meta http-equiv="Content-Type" content="${aier_content_type}" />
<title><s:property value="ev_title" /></title>
<meta name="keywords" content="${aier_keyworks}" />
<meta name="description" content="${aier_description}" />
<link rel="stylesheet" type="text/css" href="${aier_css_url}jp/1.css" />
<link href="${aier_css_url}jq/jq.css" rel="Stylesheet" />
<link rel="stylesheet" href="${aier_css_url}${aier_jqui_css}/ui.css" />
<link rel="stylesheet" href="${aier_css_url}comm/text.css" />
<link rel="stylesheet" href="${aier_css_url}admin/admin.css" />

<script type="text/javascript" src="${aier_js_url}j.js"></script>
<script type="text/javascript" src="${aier_js_url}b.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/1.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/msg.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/afu.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/hh/ui.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/block.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/arrayList.js"></script>
<script type="text/javascript" src="${aier_js_url}jc/cj.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/jq.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/cn.js"></script>
<script type="text/javascript" src="${aier_js_url}comm/text.js"></script>
</head>
<script type="text/javascript"> 
$(document).ready(function(){
   	var myTable = document.getElementById("viUpDatas"); 
	myTable.style.display ="none";
});
</script>
<body style="background-color: #EEF2FB;">
    
    <div style="background-color: #EEF2FB;width: 100%;height: 700px; ">
      
                    <div id="tabs">
                    <ul>
                        <li><a href="#tabs-1">视频设备</a></li>
                    </ul>
                    <div id="tabs-1" style="height: 500px;">
                        <div class="d_content">
                            <div class="d_scnOut">
                                <div class="d_scname">
                                    <label for="txt_tName">设备sn:</label>
                                </div>
                                <div class="d_sctext">
                                    <input type="text" id="viSn">
                                </div>
                            </div>
                            <div class="d_scnOut">
                                <div class="d_scname">
                                    <label for="txt_tName">用户名:</label>
                                </div>
                                <div class="d_sctext">
                                    <input type="text" id="viUser">
                                </div>
                            </div>
                            <div class="d_scnOut">
                                <div class="d_scname">
                                    <label for="txt_tName">URL:</label>
                                </div>
                                <div class="d_sctext">
                                    <input type="text" id="viUrl">
                                </div>
                            </div>
                            <div style="margin-top: -120px;margin-left: 320px;">
                                <div class="d_scnOut">
                                    <div class="d_scname">
                                        <label>状态:</label>
                                    </div>
                                    <div class="sel_region">
                                        <select id="viState"><option value=10>启用</option><option value=0>停用</option></select>
                                    </div>
                                </div>
                                <div class="d_scnOut">
	                                <div class="d_scname">
	                                    <label for="txt_tName">密码:</label>
	                                </div>
	                                <div class="d_sctext">
	                                    <input type="text" id="viPsd">
	                                </div>
	                            </div>
	                            <div class="d_scnOut">
                                    <div class="d_scname">
                                        <label>设备厂家:</label>
                                    </div>
                                    <div class="sel_region">
                                        <s:select list="vs" id="viEqVe"></s:select>
                                    </div>
                                </div>
                            </div>
                            <div style="margin-top: -45px;margin-left: 650px;">
                                <button id="viSure"
                                    onclick="hide()" value="确定"
                                    class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"
                                    role="button" aria-disabled="false">
                                    <span class="ui-button-text">确定</span>
                                </button>
                            </div>
					<br>
					<table id="viUpDatas" width='90%' border='1' bordercolor='#a0c6e5' style='border-collapse:collapse;' class='tableSiz1'>
						<tr><td colspan=10 bgcolor='#CCFF00'>修改设备信息</td></tr><tr>
						<tr><td width="18%">设备sn</td><td width="18%">状态</td><td width="24%">用户名</td><td width="24%">密码</td>
							<td>URL</td><td width="24%">设备厂家</td><td width="16%">操作</td>
						</tr>
						<tr>
						   <td><input type="text" style="margin:0px;vertical-align:middle;"id="viUpSn"></td>
						   <td><select id="viUpState" style="width: 100px;">
								   <option value=10>启用</option>
								   <option value=0>停用</option>
							   </select>
						   </td>
						   <td><input type="text" style="margin:0px;vertical-align:middle;" id="viUpUser"></td>
						   <td><input type="text" style="margin:0px;vertical-align:middle;" id="viUpPsd"></td>
						   <td><input type="text" style="margin:0px;vertical-align:middle;" id="viUpUrl"></td>
						   <td><s:select list="vs" id="viUpEqVe" style="width: 100px;"></s:select></td>
						   <td><button value="确定" id="viUpSure" onclick="updateD()">确定</button></td>
						</tr>
						<tr><td colspan="7"><input type="text" id="viUpDelvid" style="visibility:hidden"></td></tr>
					</table>			
					
					<br>
					<table style="width:90%">
						<tr><td><div id="viUpdelDatasDiv"></div></td></tr>
						<tr><td><div id=icCdate class="jqpage"></div></td></tr>
					</table>
					</div>
					</div>
					</div>
    </div>
	<script type="text/javascript">
	   $("#tabs").tabs();
		function show(){
		 	var myTable= document.getElementById("viUpDatas"); 
		 	myTable.style.display ="block";
		}
		
		function hidden(){ 
			var myTable = document.getElementById("viUpDatas"); 
			myTable.style.display ="none";
		}
		//向数据库写入数据
		function hide() {
			var fun = function(data) {
				if (data.s == 1) {
					alert("成功");
				} else {
					alert("失败");
				}
			};
			exeAjax(
					ajaxUrl("${aier_url}zxadminjs/video_videoReg${aier_suffix}"),
					fun, {
						"sn" : $('#viSn').val(),
						"state" : $('#viState').val(),
						"user" : $('#viUser').val(),
						"pwd" : $('#viPsd').val(),
						"url" : $('#viUrl').val(),
						"supplier" : $('#viEqVe').val(),
					});
		}

		//显示信息
		function displayDatasDiv(p) {
		
			var fun = function(data) {
				var temp = "<table width='100%' border='1' bordercolor='#a0c6e5' style='border-collapse:collapse;' class='tableSiz1'>"
						  +"<tr><td colspan=10 bgcolor='#CCFF00'>设备信息</td></tr><tr><td width='15%'>设备sn</td><td width='15%'>状态</td><td width='15%'>用户名</td>"
						  +"<td width='20%'>密码</td><td width='20%'>URL</td><td width='20%'>设备厂家</td><td colspan=2 width='30%'>操作</td></tr>";	
				if (data.s == 1 && undefined != data.vilist
						&& data.vilist.length > 0) {	
					for ( var i = 0; i < data.vilist.length; i++) {
						var tsn = data.vilist[i];
						if (tsn.state == 10) {
							tsn.state = "启用";
						} else if (tsn.state == 0) {
							tsn.state = "停用";
						}
						temp += "<tr><td>"+tsn.sn+"</td><td>"+tsn.state+"</td><td>"+tsn.user+"</td><td>"+tsn.pwd+"</td><td>"+tsn.url+"</td><td>"+data.vs[tsn.supplier]
								+"</td><td><input type='button' class='recordsbut2' value='修改' onclick='updateDataDIV("+tsn.vid+")'/></td>"
								+"<td><input type='button' value='删除' class='recordsbut2' onclick='DeleteD("+tsn.vid+")'/></td></tr>";

					}
				}
				$("#icCdate").pager({
				pagenumber : data.page,
				pagecount : data.page_count,
				buttonClickCallback : function(page) {
					displayDatasDiv(page);
				}
			});
				temp += "</table>";
				$('#viUpdelDatasDiv').html(temp);
			};
			exeAjax(
					ajaxUrl("${aier_url}zxadminjs/video_videolist${aier_suffix}"),
					fun, {
					"page": p,
					});

		}

		//修改
		function updateDataDIV(vid) {
			var fun = function(data) {
				//var temp = "";
				//$("#enUpDelDiv").html($("#enUpDelDiv").html()+temp);
				//$('#enUpDelSn').val(data.);
				$('#viUpDelvid').val(data.videoDevice.vid);
				$('#viUpSn').val(data.videoDevice.sn);
				$('#viUpState').val(data.videoDevice.state);
				$('#viUpUser').val(data.videoDevice.user);
				$('#viUpPsd').val(data.videoDevice.pwd);
				$('#viUpUrl').val(data.videoDevice.url);
				$('#viUpEqVe').val(data.videoDevice.supplier);

				$('#viUpDatas').show();

			};
			exeAjax(
					ajaxUrl("${aier_url}zxadminjs/video_searchentrbyvid${aier_suffix}"),
					fun, {
						"vid" : vid
					});
		}

		function updateD() {
			hidden();
			var fun = function(data) {
				if(1==data.s){
					alert("修改成功");
				};
				displayDatasDiv(data.page);

			};
			exeAjax(
					ajaxUrl("${aier_url}zxadminjs/video_videoupdate${aier_suffix}"),
					fun, {
						"vid" : $('#viUpDelvid').val(),
						"sn" : $('#viUpSn').val(),
						"state" : $('#viUpState').val(),
						"user" : $('#viUpUser').val(),
						"pwd" : $('#viUpPsd').val(),
						"url" : $('#viUpUrl').val(),
						"supplier" : $('#viUpEqVe').val(),
					});
		}

		//删除
		function DeleteD(vid) {
			var fun = function(data) {
				if (data.s == 1) {
					displayDatasDiv(data.page);
				}
				;
			};
			exeAjax(
					ajaxUrl("${aier_url}zxadminjs/video_videodelete${aier_suffix}"),
					fun, {
						"vid" : vid,
					});
		}
		displayDatasDiv();
	</script>
</body>
</html>